<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./js/vue.js"></script>
  </head>
  <body>
    <div id="app">
      <button @click="addTea">添加一个数据</button>
      <ul>
        <li v-for="item,index in teachers" :key="item.id">
          <h2>姓名：{{ item.name }}</h2>
          <p>爱好：{{ item.hobby }}</p>
        </li>
      </ul>
    </div>
  </body>
</html>
<script>
  Vue.config.productionTip = false;
  const vm = new Vue({
    el: '#app',
    data() {
      return {
        teachers: [
          { id: 1, name: '余维海', hobby: '金城会所' },
          { id: 2, name: '陈伟', hobby: '888号为您服务' },
          { id: 3, name: '老李', hobby: '学习讲课' },
        ],
      };
    },
    methods: {
      addTea() {
        const newTea = { id: 4, name: '婉丽', hobby: '逛街' };
        this.teachers.unshift(newTea);
      },
    },
  });
</script>
